package com.web_bloks.mvc.client;

import java.util.LinkedHashMap;


/**
 * 
 * @author Jean-Lou Dupont
 *
 */
public class Model extends Object implements IModel {

	static Model instance = null;
	
	/**
	 * Mapping of proxyNames to IProxy instances
	 */
	protected LinkedHashMap<String, IProxy> proxyMap;

	
	protected Model() {
		super();
		instance = this;
		this.proxyMap = new LinkedHashMap<String, IProxy>();	
		initializeModel();
	}
	
	public static Model getInstance() {
		if (null==instance) {
			instance = new Model();
		}
		return instance;
	}

	/**
	 * Override
	 */
	protected void initializeModel( ) {
	}

	/**
	 * Registration
	 * 
	 * @param proxy
	 */
	public void registerProxy(IProxy proxy) {
		this.proxyMap.put( proxy.getProxyName(), proxy );
	}

	public IProxy removeProxy(String proxyName) {
		return (IProxy) this.proxyMap.remove( proxyName );
	}

	public IProxy retrieveProxy(String proxyName) {
		return (IProxy) this.proxyMap.get( proxyName );
	}


}
